/*
	File: fn_saveGear.sqf
	Author: Bryan "Tonic" Boardwine
	
	Description:
	Saves the player / cops gear in a formatted array.
	
	
["srifle_EBR_F","",["20Rnd_762x51_Mag","Titan_AT"],"U_B_CTRG_1","V_PlateCarrierH_CTRG","B_Carryall_oucamo",["ItemMap","ItemCompass","ItemWatch","ItemRadio","B_UavTerminal","NVGoggles_OPFOR","Binocular","G_Tactical_Clear","H_Beret_blk"],["muzzle_snds_B","acc_flashlight","optic_LRPS"],["","",""],[],["20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag"],["20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag"],["20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","20Rnd_762x51_Mag","Titan_AT","Titan_AT"],"launch_B_Titan_short_F"]

this addaction ["<t color='#4876ff'>Load Gear</t>",{call EWDB_fnc_DBLoadGear},nil,8001];
this addaction ["<t color='#4876ff'>Save Gear</t>",{call EWDB_fnc_DBSaveGear},nil,8000];
this addaction ["<t color='#4876ff'>Arsenal</t>",{ ["Open",true] call BIS_fnc_arsenal; },nil,7999];
	
	
*/
private["_primary","_handgun","_magazines","_uniform","_vest","_backpack","_items","_primitems","_secitems","_handgunitems","_uitems","_vitems","_bitems","_curWep"];
//gearold = gear;
//Old format / code
_primary = primaryWeapon player;
_secondary = secondaryWeapon player; 
_handgun = handGunWeapon player;
_magazines = [];
_uniform = uniform player;
_vest = vest player;
_backpack = backpack player;
_items = assignedItems player;
_primitems = primaryWeaponItems player;
_secitems = secondaryWeaponItems player;
_handgunitems = handGunItems player;
_uitems = [];
_vitems = [];
_bitems = [];
if(_uniform != "") then {{_uitems set[count _uitems,_x];} foreach (uniformItems player);};
if(_vest != "") then {{_vitems set[count _vitems,_x];} foreach (vestItems player);};
if(_backpack != "") then {{_bitems set[count _bitems,_x];} foreach (backPackItems player);};

if(goggles player != "") then { _items set[count _items, goggles player]; };
if(headgear player != "") then { _items set[count _items, headgear player]; };
if(count (primaryWeaponMagazine player) > 0) then
{
	{
		_magazines set[count _magazines,_x];
	} foreach (primaryWeaponMagazine player);
};

if(count (secondaryWeaponMagazine  player) > 0) then
{
	{
		_magazines set[count _magazines,_x];
	} foreach (secondaryWeaponMagazine  player);
};

if(count (handgunMagazine player) > 0) then
{
	{
		_magazines set[count _magazines,_x];
	} foreach (handgunMagazine player);
};

//Hard code for Laser Desigantor batteries
_curWep = currentWeapon player;
if("Laserdesignator" in assignedItems player) then
{
	player selectWeapon "Laserdesignator";
	if(currentMagazine player != "") then {_magazines set[count _magazines,(currentMagazine player)];};
};

player selectWeapon _curWep;

gear = [_primary,_handgun,_magazines,_uniform,_vest,_backpack,_items,_primitems,_secitems,_handgunitems,_uitems,_vitems,_bitems,_secondary];


["a3_gear",gear] call EWDB_fnc_DBUpdate;
hint "Gear Saved to Database";
